package com.oceansoft.mobile.econsole.modules.security.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.oceansoft.mobile.econsole.common.util.web.PageUtil;
import com.oceansoft.mobile.econsole.modules.base.entity.Pager;
import com.oceansoft.mobile.econsole.modules.base.entity.Query;
import com.oceansoft.mobile.econsole.modules.security.entity.Baykscj;
import com.oceansoft.mobile.econsole.modules.security.persistence.SecurityMapper;
import com.oceansoft.mobile.econsole.modules.security.service.securityService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by zeng on 2016/8/30.
 */
@Service
public class securityServiceImpl implements securityService{

    @Resource
    private SecurityMapper securityMapper;


    public Pager<Baykscj> findSecurity(Query query) {
        PageHelper.startPage(query.getPageNum(), query.getNumPerPage(), true);
        Page<Baykscj> page = (Page<Baykscj>) securityMapper.findSecurity(query);
        return PageUtil.page2pager(page, query);
    }

    public void saveBaykscj(List<Baykscj> baykscjList) {
        for (int i = 0; i < baykscjList.size(); i++) {
            securityMapper.saveBaykscj(baykscjList.get(i));
        }
    }
}
